<?php
function loopDir($dir) {
    $handle = opendir($dir);
    while (false !== ($file = readdir($handle))){
        if ($file != '.' && $file != '..'){
            $filename = $dir.'/'.$file;
            echo $filename.PHP_EOL;
            if (filetype($filename) == 'dir'){
                loopDir($filename);
            }
        }
    }
}
$dir = './test1';
loopDir($dir);